package com.tistory.admin.common.util;
import java.io.*;
import java.net.*;
import java.util.*;
public class postto{

	private void fetchURL (String urlString,String user,String pass) {	

		try {
			URL url;
			URLConnection urlConn;
			DataOutputStream printout;
			DataInputStream input;

			Properties sysProperties = System.getProperties();

			sysProperties.put("proxyHost", "www.easyshop.co.kr");
			sysProperties.put("proxyPort", "80");
			sysProperties.put("proxySet", "true");
			url = new URL (urlString);
			urlConn = url.openConnection();
			urlConn.setDoInput (true);

			urlConn.setDoOutput (true);

			urlConn.setUseCaches (false);

			urlConn.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");

			printout = new DataOutputStream (urlConn.getOutputStream ());

			String content = "USERNAME=" + URLEncoder.encode (user) + "&PASSWORD=" + URLEncoder.encode (pass);

			printout.writeBytes (content);
			printout.flush ();
			printout.close ();

			input = new DataInputStream (urlConn.getInputStream ());
			FileOutputStream fos=new FileOutputStream("postto.txt");
			String str;
			while (null != ((str = input.readLine())))
			{

				if (str.length() >0)
				{
					fos.write(str.getBytes());
					fos.write(new String("\n").getBytes());
				}
			}
			input.close ();
		}
		catch(MalformedURLException mue){ System.out.println (mue);}
		catch(IOException ioe){ System.out.println (ioe);}
	}
	public static void main (String args[]) {
		postto au=new postto();
		String webPage = "https://www.easyshop.co.kr/taxVan/taxVanTrxDay.kicc";
		String name = "lbg7749";
		String password = "ljh07002";
		
		au.fetchURL(webPage,name,password);
	}
}